package com.tanhua.server.controller;

import com.tanhua.server.service.VideoService;
import com.tanhua.vo.PageResult;
import com.tanhua.vo.VideoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/smallVideos")
public class SmallVideosController {
    @Autowired
    private VideoService videoService;

    /**
     * 保存小视频
     * @param videoThumbnail
     * @param videoFile
     * @return
     */
    @PostMapping
    public ResponseEntity saveVideo(MultipartFile videoThumbnail,MultipartFile videoFile) throws IOException {
        videoService.saveVideo(videoThumbnail,videoFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 小视频列表
     * @param page
     * @param pagesize
     * @return
     */
    @GetMapping
    public ResponseEntity videos(@RequestParam(defaultValue = "1")Integer page,
                                 @RequestParam(defaultValue = "10")Integer pagesize ){
        PageResult pageResult = videoService.videos(page,pagesize);
        return ResponseEntity.ok(pageResult);
    }



}
